﻿@model EntityList<Nav>
@using NewLife.Web;
@using XCode;
@using XCode.Membership;
@using NewLife.CMX;
@{
    var fact = ViewBag.Factory as IEntityOperate;
    var page = ViewBag.Page as Pager;
}
<div class="panel panel-default">
    <div class="panel-body">
        @Html.Partial("_List_Toolbar")
    </div>
    <div class="table-responsive">
        <table class="table table-bordered table-hover table-striped table-condensed">
            <thead>
                <tr>
                    <th>编号</th>
                    <th>名称</th>
                    <th>频道</th>
                    <th>链接</th>
                    <th>排序</th>
                    <th>启用</th>
                    <th>升</th>
                    <th>降</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var entity in Nav.Root.AllChilds)
                {
                    var p = entity.Parent;
                    if (p == null)
                    {
                        p = Nav.Root;
                    }
                    <tr>
                        <td>@entity.ID</td>
                        <td>@entity.TreeNodeName</td>
                        <td>@entity.CategoryName</td>
                        <td>@entity.Url</td>
                        <td>@entity.Sort</td>
                        @Html.Partial("_List_Data_Item", new Pair(entity, fact.Table.FindByName("Enable")))
                        <td>
                            @if (p != null && entity != p.Childs[0])
                            {
                                <a href="@Url.Action("Up", new { id = entity.ID })"><span class="glyphicon glyphicon-arrow-up" style="color: green;"></span></a>
                            }
                        </td>
                        <td>
                            @if (p != null && entity != p.Childs[p.Childs.Count - 1])
                            {
                                <a href="@Url.Action("Down", new { id = entity.ID })"><span class="glyphicon glyphicon-arrow-down" style="color: red;"></span></a>
                            }
                        </td>
                        <td>
                            @Html.Partial("_List_Data_Action", entity)
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
    <div class="panel-footer">
        <p>
            @Html.Partial("_List_Pager")
        </p>
    </div>
</div>